# Created by: Veniamin Gvozdikov <vg@FreeBSD.org>
# $FreeBSD: head/www/mongrel2/Makefile 363371 2014-07-29 18:41:15Z adamw $

PORTNAME=	mongrel2
PORTVERSION=	1.9.1
CATEGORIES=	www
MASTER_SITES=	https://github.com/zedshaw/%SUBDIR%/
MASTER_SITE_SUBDIR=	${PORTNAME}/releases/download/v${PORTVERSION}
DISTNAME=	${PORTNAME}-v${PORTVERSION}

MAINTAINER=	vg@FreeBSD.org
COMMENT=	Is an application, language, and network arch

LICENSE=	BSD3CLAUSE
LICENSE_FILE=	${WRKSRC}/LICENSE

LIB_DEPENDS=	libzmq.so:${PORTSDIR}/net/libzmq2

USES=	gmake
USE_SQLITE=	yes
MAKE_FLAGS=	freebsd
EXAMPLES_LIST=	bbs \
		chat \
		configs \
		http_0mq \
		kegogi \
		mp3stream \
		procer \
		python \
		tornado \
		zcov

OPTIONS_DEFINE=		EXAMPLES

.include <bsd.port.options.mk>

.if ${PORT_OPTIONS:MEXAMPLES}
PLIST_SUB+=	EXAMPLES=""
.else
PLIST_SUB+=	EXAMPLES="@comment "
.endif

# PolarSSL is already in ports tree
post-extract:
	${RM} -Rf ${WRKSRC}/src/polarssl/
	${RM} ${WRKSRC}/src/polarssl_config.h

post-patch:
	@${REINPLACE_CMD} -e 's#/usr/local#${LOCALBASE}#g' ${WRKSRC}/Makefile

post-install:
.if ${PORT_OPTIONS:MEXAMPLES}
	@${MKDIR} ${STAGEDIR}/${EXAMPLESDIR}
.for examples in ${EXAMPLES_LIST}
	@cd ${WRKSRC}/examples && ${COPYTREE_SHARE} ${examples} ${STAGEDIR}/${EXAMPLESDIR}
.endfor
.endif

.include <bsd.port.mk>
